
package fileby.util;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 *
 * @author Oscar
 */
 public class TransferableFileUtil implements Transferable {

 	private DataFlavor [] supportedFlavors = {DataFlavor.javaFileListFlavor};
 	private List<File> fileList;

 	public TransferableFileUtil (List<File> fileList) {
	 this.fileList = fileList;
	}

        @Override
	public  DataFlavor [] getTransferDataFlavors () {
	    return supportedFlavors.clone();
	}
        @Override
	public boolean isDataFlavorSupported (DataFlavor flavor) {
	    return (flavor.equals (DataFlavor.javaFileListFlavor));
	}
        @Override
	public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException, IOException {
            if (flavor.equals (DataFlavor.javaFileListFlavor))
                return (fileList);
	   else
                throw new UnsupportedFlavorException(flavor);
	 }
   }
